package pe.edu.upc.xcode.food.dao.impl;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import pe.edu.upc.xcode.food.dao.CategoriaDAO;
import pe.edu.upc.xcode.food.domain.Categoria;
import pe.edu.upc.xcode.food.domain.Categoriaplato;
import pe.edu.upc.xcode.food.domain.Plato;
@Repository
@Transactional
public class CategoriaDAOImpl implements CategoriaDAO {

    @PersistenceContext
    private EntityManager em;
	
	public CategoriaDAOImpl() {
		// TODO Auto-generated constructor stub
	}

	public Integer save(Categoria object) {
		// TODO Auto-generated method stub
		return null;
	}

	public Integer update(Categoria object) {
		// TODO Auto-generated method stub
		return null;
	}

	public Integer detele(Categoria object) {
		// TODO Auto-generated method stub
		return null;
	}

	public Categoria find(Categoria object) {
		// TODO Auto-generated method stub
		Query query = em.createQuery("SELECT cp from Categoria cp where cp.codigo=:p_codigo");
		query.setParameter("p_codigo", object.getCodigo());
		Categoria cat= (Categoria) query.getSingleResult();
		return cat;
	}

	public List<Categoria> findAll() {
		Query query = em.createQuery("SELECT cp from Categoria cp where cp.estado='A' ");
		List<Categoria> list= query.getResultList();
		return list;
	}


}
